/*

A clock holds three components of time: HOUR, MINUTE, SECOND. Implement a class Clock according to the following main function and its output in comments. This class has three primary member functions as :
(1) void get(int& hour, int& minute, int* second): Return the components (hour, minute and second) of current time by arguments.
(2) void update(): Increase 1 second to current time.
(3) bool adjust(int h, int m, int s): If all the arguments is valid, this function sets current hour to h, sets current minute to m, sets current second to s and return true. If any argument is invalid, the current time is not changed and this function return false.*/
#include <iostream>
using namespace std;

class Clock{
private:
    int hour,min,second;
public:
    Clock(int h=0,int m=0,int s=0):hour(h),min(m),second(s){};
    void get(int& h,int& m,int* s){
        h = hour;
        m = min;
        *s = second;
    };
    bool adjust(int h=0,int m=0,int s=0){
        if(h<0||h>23||m<0||m>59||s<0||s>59)
            return false;
        hour = h;
        min = m;
        second = s;
        return true;
    }
    void update(){
        second++;
        if(second==60){
            second=0;
            min++;
        }
        if(min==60){
            min=0;
            hour++;
        }
        if(hour==24)
            hour=0;
    }
    friend ostream& operator<<(ostream& oo,Clock c){
        oo<<c.hour<<':'<<c.min<<':'<<c.second;
        return oo;
    };
};
int main() {
    int h, m, s;
    cout<<testClock<<endl;
    testClock.get(h, m, &s);
    cout << "OUT-1: " << h <<":" << m << ":" << s << endl; // OUT-1: 0:0:0
    testClock.adjust(13,5, 59);
    testClock.update();
    cout << "OUT-2: " << testClock << endl; // OUT-2: 13:6:0
    testClock.adjust(23,59, 58);
    testClock.update();
    cout << "OUT-3: " << testClock << endl; // OUT-3: 23:59:59
    testClock.update();
    cout << "OUT-4: " << testClock << endl; // OUT-4: 0:0:0
    return 0;
}